/**
 * @ngdoc config
 * @name ui.router
 * @description
 * # Application_NG：路由配置
 */
(function () {
    'use strict';
    appModule.config([
        '$stateProvider', '$urlRouterProvider', '$ocLazyLoadProvider',
        function ($stateProvider, $urlRouterProvider, $ocLazyLoadProvider) {
            // console.log(CURACCOUNTPERMISSIONS);
            //判断是否有权限，传入权限名称,返回布尔值，true为有权限；false为没有权限
            function checkPermission(permissionName) {
                if ($.inArray(permissionName, CURACCOUNTPERMISSIONS) == -1) {
                    return false;
                } else {
                    return true;
                }
            };

            //懒加载服务配置
            $ocLazyLoadProvider.config({
                debug: false,
                events: true,
                modules: []
            });

            $urlRouterProvider.otherwise('/app/files-index'); //默认页面
            $urlRouterProvider.when('/app', '/app/files-index'); //指定转换页面

            //首页
            $stateProvider.state('app.welcome', {
                url: '/welcome',
                templateUrl: 'app/viewModules/welcome.html',
                resolve: {
                    loadMyFiles: function ($ocLazyLoad) {
                        return $ocLazyLoad.load({
                            name: 'Application_NG',
                            cache: false,
                            files: []
                        })
                    }
                }
            });

            //布局页
            $stateProvider.state('app', {
                url: '/app',
                templateUrl: 'app/viewModules/Common/layout.html',
                resolve: {
                    loadCtrlAndDirectives: function ($ocLazyLoad) {
                        return $ocLazyLoad.load({
                            name: 'Application_NG',
                            files: [
                                'app/viewModules/Common/layout.js',
                                'app/directives/loading/loading.js',
                                'app/directives/header/header.js',
                                'app/directives/header/header-notification/header-notification.js',
                                'app/directives/sidebar/sidebar.js',
                                'app/directives/sidebar/sidebar-search/sidebar-search.js'
                            ]
                        })
                    }
                }
            });

            //文件主页
            if (true) {
                $stateProvider.state('app.files-index', {
                    url: '/files-index',
                    templateUrl: 'app/viewModules/files/index.html',
                    resolve: {
                        loadMyFiles: function ($ocLazyLoad) {
                            return $ocLazyLoad.load({
                                name: 'Application_NG',
                                files: [
                                       'app/viewModules/files/index.js',
                                       'app/viewModules/files/index.css',
                            ]
                            })
                        }
                    }

                });
            }
            //文件搜索
            if (true) {
                $stateProvider.state('app.files-search', {
                    url: '/files-search',
                    templateUrl: 'app/viewModules/files/search.html',
                    params: { paramsObj: null, search_text: null },
                    resolve: {
                        loadMyFiles: function ($ocLazyLoad) {
                            return $ocLazyLoad.load({
                                name: 'Application_NG',
                                files: [
                                    'app/viewModules/files/normalize.min.css',
                                    'app/viewModules/files/style.css',
                                    'app/viewModules/files/search.css',
                                    'app/viewModules/files/search.js',
                                ]
                            })
                        }
                    }

                });
            }
            
            //文件上传
            if (true) {
                $stateProvider.state('app.filesUpload-index', {
                    url: '/filesUpload-index',
                    templateUrl: 'app/viewModules/filesUpload/index.html',
                    resolve: {
                        loadMyFiles: function ($ocLazyLoad) {
                            return $ocLazyLoad.load({
                                name: 'Application_NG',
                                files: ['app/viewModules/filesUpload/index.css',
                                'app/viewModules/filesUpload/index.js']
                            })
                        }
                    }
                });
            }


        }
    ])
})();